// Spu管理页面相关api
import productRequest from '@/utils/productRequest'

// export const req = ()=>productRequest({url:``,method:''})

// 获取SPU分页列表数据
// /admin/product/{page}/{limit}  get  data:{page, limit, category3Id}
export const reqGetSpuList = (page, limit, category3Id) => productRequest({ url: `/admin/product/${page}/${limit}`, methods: 'get', params: { category3Id } })

// 获取spu基本信息
// /admin/product/getSpuById/{spuId}  get
export const reqGetSpuInfo = (spuId) => productRequest({ url: `/admin/product/getSpuById/${spuId}`, method: 'get' })

// 获取品牌列表数据
// /admin/product/baseTrademark/getTrademarkList   get
export const reqGetTrademarkList = () => productRequest({ url: `/admin/product/baseTrademark/getTrademarkList`, method: 'get' })

// 获取spu图片墙数据
// /admin/product/spuImageList/{spuId}  get
export const reqGetSpuImageList = (spuId) => productRequest({ url: `/admin/product/spuImageList/${spuId}`, method: 'get' })

// 获取spu主要销售属性列表数据
// /admin/product/baseSaleAttrList   get
export const reqGetSaleAttrList = () => productRequest({ url: `/admin/product/baseSaleAttrList`, method: 'get' })

// 获取spu销售属性列表
// /admin/product/spuSaleAttrList/{spuId}  get
export const reqGetSpuSaleAttrList = (spuId) => productRequest({ url: `/admin/product/spuSaleAttrList/${spuId}`, method: 'get' })

// 添加/修改spu信息
// /admin/product/saveSpuInfo   post  |添加
// /admin/product/updateSpuInfo  post  | 修改
export const reqSaveOrUpdateSpuInfo = (spuInfo) => {
    if (!spuInfo.id) { // 没有id 添加spu
        return productRequest({ url: `/admin/product/saveSpuInfo`, method: 'post', data: spuInfo })
    } else { // 修改spu
        return productRequest({ url: `/admin/product/updateSpuInfo`, method: 'post', data: spuInfo })
    }
}

// 删除spu
// /admin/product/deleteSpu/{spuId}   delete
export const reqDeleteSpu = (spuId) => productRequest({ url: `/admin/product/deleteSpu/${spuId}`, method: 'delete' })

// 保存sku
// /admin/product/saveSkuInfo   post
export const reqSaveSku = (skuInfo) => productRequest({ url: `/admin/product/saveSkuInfo`, method: 'post', data: skuInfo })

// 查看sku列表
// /admin/product/findBySpuId/{spuId}  get
export const reqGetSkuList = (spuId) => productRequest({ url: `/admin/product/findBySpuId/${spuId}`, method: 'get' })


